home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 80 / CD Actual 80 Julio-Agosto 2003.iso / Linux / LinuxGazette / lg / issue91 / misc / mathew / code / pvcl.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-05-20  |  4.9 KB  |  138 lines

  1. /*  Copyright (C) 2003 Cherry George Mathew <cherry@freeshell.org>
  2.  
  3.     This program is free software; you can redistribute it and/or modify
  4.     it under the terms of the GNU General Public License as published by
  5.     the Free Software Foundation; either version 2 of the License, or
  6.     (at your option) any later version.
  7.     
  8.     This program is distributed in the hope that it will be useful,
  9.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.     GNU General Public License for more details.
  12.     
  13.     You should have received a copy of the GNU General Public License
  14.     along with this program; if not, write to the Free Software
  15.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17.  
  18. #include <linux/init.h> 
  19. #include <linux/pci.h>
  20. #include <linux/i2c.h>
  21. #include <linux/i2c-algo-bit.h>
  22. #include <linux/videodev.h>
  23. /* We'll upgrade to V4L2, once we're 
  24.  * up and include.
  25.  */
  26. #include <linux/spinlock.h>   /* Just for extra safety. We're writing into \
  27.                  reserved vga io space. Don't want any funny\
  28.                  stuff there. */
  29. /* Functional level debugging */
  30. #define dprintk(fmt, args...) if (debug>=1) printk(KERN_DEBUG "pvcl-debug: " fmt, ## args);
  31. /* Debugging single functions */
  32. #define tprintk(fmt, args...) if (debug>=2) printk(KERN_DEBUG "pvcl-debug: " fmt, ## args);
  33. /* Warning - too verbose. Debugging port conversations. */
  34. #define vprintk(fmt, args...) if (debug>=3) printk(KERN_DEBUG "pvcl-debug:" fmt, ## args);
  35.  
  36. #define MAX_CARDS 2
  37.  
  38. #define GD_SR_OFFSET 0x3c4
  39. #define GD_GR_OFFSET 0x3ce
  40. #define GD_CR_OFFSET 0x3d4
  41.  
  42. #define GD_CHROMA_KEY 0x80
  43.  
  44. struct gd_status_t
  45. {
  46.     struct video_buffer * vbuf_p;
  47.         struct video_window * vwin_p;
  48.     struct video_tuner  * vtun_p;
  49.     struct video_channel *vchan_p;
  50.         struct video_picture *vpict_p;
  51.     struct i2c_adapter  * adapter_p;
  52.     unsigned long freq;
  53. };
  54.  
  55. /* Card structure below holds info about the adapter card on which the \
  56.  * I2C bus sits on.
  57.  */
  58.  
  59.  
  60. struct clgd54xx_card{
  61.         unsigned short clgd54xx_pci_dev_id;    
  62.         int vram;
  63.     int model;
  64.         unsigned long gd_io_base;
  65.     struct pci_dev *clgd54xx_pci_dev_p;
  66.     long spinflags;
  67.     spinlock_t spun_lock;
  68.     unsigned long i2c_state;
  69.     struct i2c_adapter *clgd54xx_adapter_p;
  70.         struct i2c_algo_bit_data *clgd54xx_bitbang_adapter_p;
  71.         struct gd_status_t * drv_stat_p;
  72. };
  73.  
  74. /* Function Definitions. */
  75. /* Register level functions. */
  76.  
  77. static inline unsigned io_readb (unsigned);
  78. static inline void io_writeb (unsigned, unsigned);
  79.  
  80. static inline void gd_write_sr(struct clgd54xx_card *, unsigned char ,unsigned );
  81. static inline void gd_write_gr(struct clgd54xx_card *, unsigned char ,unsigned );
  82. static inline void gd_write_cr(struct clgd54xx_card *, unsigned char ,unsigned );
  83.  
  84. static inline unsigned gd_read_sr(struct clgd54xx_card *, unsigned );
  85. static inline unsigned gd_read_gr(struct clgd54xx_card *, unsigned reg);
  86. static inline unsigned gd_read_cr(struct clgd54xx_card *, unsigned reg);
  87.  
  88.  
  89. /* VGA Wrapper functions */
  90. static void gd_bit_copy(unsigned long * dest, int dest_start,
  91.             unsigned long * src, int src_start, int src_stop);
  92. static long gd_window_init(struct clgd54xx_card *);
  93.  
  94. /* VGA hardware video programming functions. */
  95.  
  96. static void gd_enable_window(struct clgd54xx_card *);
  97. static void gd_disable_window(struct clgd54xx_card *);
  98. static void gd_set_vbuf1(struct clgd54xx_card *, unsigned long );
  99. static void gd_set_vbuf2(struct clgd54xx_card *, unsigned long );
  100. static unsigned long gd_get_vbuf1(struct clgd54xx_card *);
  101. static unsigned long gd_get_vbuf2(struct clgd54xx_card *);
  102. static void gd_set_pitch(struct clgd54xx_card * card_p, unsigned long ); 
  103. static unsigned long gd_get_pitch(struct clgd54xx_card *);
  104.  
  105. /* VGA video window functions */
  106. static void gd_set_window(struct clgd54xx_card *,
  107.               struct video_window *, 
  108.               struct video_window *,
  109.               struct video_buffer *);
  110. static void gd_get_window(struct clgd54xx_card *,
  111.               struct video_window *, struct video_buffer *);
  112.  
  113. /* I2C bus bit level functions. */
  114. static void gd54xx_setsda (void *bit_adap_dat, int state); 
  115. static void gd54xx_setscl (void *bit_adap_dat, int state); 
  116. static int gd54xx_getsda (void *bit_adap_dat);
  117. static int gd54xx_getscl (void *bit_adap_dat);
  118.  
  119. /* I2C callbacks. */
  120. static int i2c_clgd54xx_init_adapter(struct clgd54xx_card *,
  121.                      struct i2c_adapter *,
  122.                      struct i2c_algo_bit_data *);
  123. static int i2c_clgd54xx_cleanup_adapter(struct clgd54xx_card *);
  124. static int i2c_clgd54xx_probe_card(struct clgd54xx_card *);
  125. static int i2c_clgd54xx_find_card(struct clgd54xx_card *);
  126. static int __init i2c_clgd54xx_init(struct clgd54xx_card *,
  127.                     struct i2c_adapter *,
  128.                     struct i2c_algo_bit_data *);
  129. static int __init i2c_clgd54xx_cleanup(struct clgd54xx_card *);
  130.  
  131. /* Generic VGA Routines */
  132.  
  133. static int gd_count_ram(struct clgd54xx_card *card_p);
  134.  
  135. /* V4L Callbacks */
  136. static void do_client_ioctl(struct file*, unsigned int cmd, void *arg);
  137.  
  138.